<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@include file="/common/common.jsp"%>
<h:css href="/css/style1/style-custom.css"/>
<%@include file="/common/skins/skin0/component.jsp" %>
<%--
- Author(s): pengweiling
- Date: 2012-07-10 15:28:09
- Description:
--%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>
      任务列表
    </title>

    
  </head>
  <body>
    <e:datasource name="criteria" type="entity" path="com.primeton.das.criteria.criteriaType" />
    <e:datasource name="page" type="entity" path="com.eos.foundation.PageCond" />
    <e:datasource name="wetasksvs" type="entity" path="com.hms.OrderMgr.order.WeTasksV" />
    <queryform id= "285e7ef2-021c-45f8-8345-bafb8bd2e50a">
      <h:form  name="query_form" action="com.hms.OrderMgr.OrderMgr.flow" checkType="blur" target="_self" method="post" onsubmit="return checkForm(this);">
        <input type="hidden" name="_eosFlowAction" value="pageQuery"/>
          <table align="center" border="0" width="100%" class="form_table">
            <tr>
              <td class="form_label">
                任务类型
              </td>
              <td colspan="1">
                <h:select property="criteria/_expr[3]/ctasktype" style="width:128px;">
                  <h:option label="" value=""/>
                  <h:option label="预订单" value="A"/>
                  <h:option label="预订修改" value="M"/>                                    
                  <h:option label="预订取消" value="C"/>                                                      
                  <h:option label="房屋上线" value="R"/>                                                      
                </h:select>
                <h:hidden property="criteria/_expr[3]/_op" value="="/>
              </td>
              <td class="form_label">
                任务编号
              </td>
              <td colspan="1">
                <h:text property="criteria/_expr[4]/itaskid"/>
                <h:hidden property="criteria/_expr[4]/_op" value="like"/>
                <h:hidden property="criteria/_expr[4]/_likeRule" value="all"/>
              </td>
              <td class="form_label">
                步骤名称
              </td>
              <td colspan="1">
                <h:text property="criteria/_expr[5]/cstepname"/>
                <h:hidden property="criteria/_expr[5]/_op" value="like"/>
                <h:hidden property="criteria/_expr[5]/_likeRule" value="all"/>
              </td>
              <td class="form_label">
                订单号
              </td>
              <td colspan="1">
                <h:text property="criteria/_expr[6]/corderno"/>
                <h:hidden property="criteria/_expr[6]/_op" value="like"/>
                <h:hidden property="criteria/_expr[6]/_likeRule" value="all"/>
              </td>
              <td class="form_label">
                审批人
              </td>
              <td colspan="1">
                <h:text property="criteria/_expr[7]/operatorname"/>
                <h:hidden property="criteria/_expr[7]/_op" value="like"/>
                <h:hidden property="criteria/_expr[7]/_likeRule" value="all"/>
                </td>              
            </tr>
            <tr>
              <td class="form_label">
                创建时间(从)
              </td>
              <td class="form_label">
                <h:hidden property="criteria/_expr[8]/_op" value="between" />
                <h:hidden property="criteria/_expr[8]/dcreated" value=" " />
                <h:hidden property="criteria/_expr[8]/_pattern" value="yyyy-MM-dd"/>
                <w:date property="criteria/_expr[8]/_min"/>	
              </td>
              <td class="form_label">
                创建时间(到)
              </td>
              <td class="form_label">
                <w:date property="criteria/_expr[8]/_max"/>	
              </td> 
              <td class="form_label">
                修改时间(从)
              </td>
              <td colspan="1">
                <h:hidden property="criteria/_expr[9]/_op" value="between" />
                <h:hidden property="criteria/_expr[9]/dmodified" value=" " />
                <h:hidden property="criteria/_expr[9]/_pattern" value="yyyy-MM-dd"/>
                 <w:date property="criteria/_expr[9]/_min"/>
              </td>
              <td class="form_label">
                修改时间(到)
              </td>
              <td colspan="1">
                 <w:date property="criteria/_expr[9]/_max"/>
              </td>  
              <td class="form_label">
                状态
              </td>
              <td colspan="1">
                <h:select property="criteria/_expr[1]/cstatus" style="width:128px;" >
                   <h:option label="" value=""/>                    
                   <h:option label="待处理" value="TODO"/> 
                   <h:option label="完成" value="COMPLETE"/>                    
                </h:select>
              </td>                            
              </tr>
              <tr class="form_bottom">
                <td colspan="10" class="form_bottom">
                  <input type="hidden" name="criteria/_entity" value="com.hms.OrderMgr.order.WeTasksV">
                  <h:hidden property="criteria/_expr[2]/cauditby"/>
                  每页显示
                  <h:text size="2" property="page/length" value="10" validateAttr="minValue=1;maxValue=100;type=integer;isNull=true" />
                  <input type="hidden" name="page/begin" value="0">
                  <input type="hidden" name="page/isCount" value="true">
                  <input type="submit" value="查询" class="button">
                </td>
              </tr>
            </table>
        </h:form>
      </queryform>
      <br/>
      <viewlist id= "cd55da46-95a4-4bc5-b9b1-48b866d56f61">
        <h:form name="page_form" action="com.hms.OrderMgr.OrderMgr.flow" method="post">
          <input type="hidden" name="_eosFlowAction" value="pageQuery" >
          <h:hiddendata property="criteria" />
          <h:hidden property="page/begin"/>
          <h:hidden property="page/length"/>
          <h:hidden property="page/count"/>
          <h:hidden property="page/isCount"/>
          
            <table align="center" border="0" width="100%" class="EOS_table">
              <tr>
                <th align="center">
                  选择
                </th>
                <th>
                  任务编号
                </th>
                <th>
                  任务类型
                </th>
                <th>
                  订单编号
                </th>
                <th>
                  步骤名称
                </th>
                <th>
                  状态
                </th>
                <th>
                  创建时间
                </th>
                <th>
                  修改时间
                </th>
                <th>
                  处理人
                </th>
              </tr>
              <w:checkGroup id="group1">
                <l:iterate property="wetasksvs" id="id1">
                  <tr class="<l:output evenOutput='EOS_table_row' />">
                    <td align="center">
                      <w:rowCheckbox>
                        <h:param name='select_objs/iorderid' iterateId='id1' property='iorderid' indexed='true' />
                        <h:param name='tasks/itaskid' iterateId='id1' property='itaskid' indexed='true' />
                        <h:param name='tasks/ctasktype' iterateId='id1' property='ctasktype' indexed='true' />
                      </w:rowCheckbox>
                    </td>
                    <td>
                      <b:write iterateId="id1" property="itaskid"/>
                    </td>
                    <td>
                      <l:equal property="ctasktype" iterateId="id1" targetValue="A">
                         预订单
                      </l:equal>
                      <l:equal property="ctasktype" iterateId="id1" targetValue="B">
                         工作账
                      </l:equal>
                      <l:equal property="ctasktype" iterateId="id1" targetValue="M">
                         订单修改
                      </l:equal>                      
                    </td>
                    <td>
                      <l:empty property="corderno" iterateId="id1">
                        <b:write iterateId="id1" property="iorderid"/>
                      </l:empty>
                      <l:notEmpty property="corderno" iterateId="id1">
                        <b:write iterateId="id1" property="corderno"/>
                      </l:notEmpty>                      
                      
                    </td>
                    <td>
                      <a href="#" onclick="showStep(<b:write iterateId="id1" property="iorderid"/>)">
                        <b:write iterateId="id1" property="cstepname"/>
                      </a>
                    </td>
                    <td>
                      <l:equal property="cstatus" iterateId="id1" targetValue="TODO">
                         待处理
                      </l:equal>  
                      <l:equal property="cstatus" iterateId="id1" targetValue="COMPLETE">
                         处理完毕
                      </l:equal>     
                    </td>
                    <td>
                      <b:write iterateId="id1" property="dcreated"/>
                    </td>
                    <td>
                      <b:write iterateId="id1" property="dmodified"/>
                    </td>
                    <td>
                      <b:write iterateId="id1" property="operatorname"/>
                    </td>
                  </tr>
                </l:iterate>
              </w:checkGroup>
              <tr>
                <td colspan="9" class="command_sort_area">
                  <div style="float:left">
                  <!-- 
                  <input type="button" value="新增预订" onclick="addRecord();" class="button">
                   -->
                  <l:greaterThan property="page/size" targetValue="0" compareType="number">
                    <input type="button" value="任务详细" onclick="updateRecord();" class="button">
                  </l:greaterThan>
                  </div>
                  <div style="float:right">
                    <l:equal property="page/isCount" targetValue="true">
                      共
                      <b:write property="page/count"/>
                      条记录 第
                      <b:write property="page/currentPage"/>
                      页/
                      <b:write property="page/totalPage"/>
                      页
                    </l:equal>
                    <l:equal property="page/isCount" targetValue="false">
                      第
                      <b:write property="page/currentPage"/>
                      页
                    </l:equal>
                    <input type="button" onclick="firstPage('page', 'pageQuery', null, null, 'page_form');" value="首页"  <l:equal property="page/isFirst" targetValue="true">disabled</l:equal> >
                    <input type="button" onclick="prevPage('page', 'pageQuery', null, null, 'page_form');" value="上页" <l:equal property="page/isFirst" targetValue="true">disabled</l:equal> >
                    <input type="button" onclick="nextPage('page', 'pageQuery', null, null, 'page_form');" value="下页" <l:equal property="page/isLast" targetValue="true">disabled</l:equal> >
                    <l:equal property="page/isCount" targetValue="true">
                      <input type="button" onclick="lastPage('page', 'pageQuery', null, null, 'page_form');" value="尾页" <l:equal property="page/isLast" targetValue="true">disabled</l:equal> >
                    </l:equal>
                  </div>
                </td>
              </tr>
            </table>

        </h:form>
      </viewlist>
      <script>
        function updateRecord(){
          var g = $id("group1");
          var frm = $name("page_form");
          if (g.getSelectLength() != 1) {
            alert("请选择一行记录！");
            return;
          }
          
          //判断是否订单修改，如果是订单修改，就设置action为modify
          var params = g.getSelectParams("tasks/ctasktype");
          for(var i = 0; i < params.length; i++){     
             if (params[i] == "M"){
               frm.elements["_eosFlowAction"].value = "modify";
             }else if (params[i] == "A"){
               frm.elements["_eosFlowAction"].value = "update";
             }
          }
                  
          frm.submit();
        }
        
        function addRecord()
        {
          var frm = $name("page_form");
          frm.elements["_eosFlowAction"].value = "insert";
          frm.submit();
        }
        function deleteRecord()
        {
          var g = $id("group1");
          var frm = $name("page_form");
          if (g.getSelectLength() < 1) {
            alert("请选择记录！");
            return;
          }
          frm.elements["_eosFlowAction"].value = "delete";
          frm.submit();
        }
        
        function showStep(orderId){
           showModal("com.hms.OrderMgr.WeTasksVSelect.flow?criteria/_expr[1]/iorderid=" + orderId + "&criteria/_expr[2]/ctasktype=R&criteria/_expr[2]/_op=<>",
                     null, 
                     null, 
                     700, 
                     480, 
                     null, 
                     null, 
                     "审批任务信息");
        }
      </script>
    </body>
  </html>
